<?php


namespace app\basic\controller;


use app\self\controller\Extend;
use think\Db;

class Classification   extends Extend
{
    protected $database = 'b_classification';

    protected $type = '分类管理';

    public function searchWhere()
    {
        $search = [
            ['field'=>'type','name'=>'类型','type'=>'select'],
        ];
        $this->assign('search',$search);
        $this->assign('searchJs',json_encode($search));
        $data['type'] = [
            ['value'=>'应用系统','key'=>'应用系统'],
            ['value'=>'集团内部控制管理','key'=>'集团内部控制管理'],
            ['value'=>'公司制度规范','key'=>'公司制度规范'],
            ['value'=>'常用表单模块区','key'=>'常用表单模块区'],
        ];
        $this->assign('selectData',$data);
    }



    public function mapSelf()
    {
        return ['is_delete'=>0];
    }



    /**
     * use   需要编辑的字段
     * user  Hugh
     * date  2021/3/30 13:55
     */
    public function getField()
    {
        $id = input('id/d',0);
        $result = DB::name($this->database)
            ->where(['id'=>$id])
            ->find();
        $edit = [
            ['field'=>'type','name'=>'类型','notNull'=>true,'value'=>$result['type'],'type'=>'select',
                'option'=>['应用系统','集团内部控制管理','公司制度规范','常用表单模块区']
            ],
            ['field'=>'name','name'=>'名称','notNull'=>true,'value'=>$result['name']],
        ];
        return $edit;
    }

    /**
     * use   数据验证
     * user  Hugh
     * date  2021/3/30 13:55
     * @param $data
     * @param $id
     */
    public function postVerification($data,$id)
    {
        if(empty($data['type'])) return fieldEmpty('类型'); //字段不能为空
        if(empty($data['name'])) return fieldEmpty('名称'); //字段不能为空
    }

}